#pragma once

#include "UMLShape.h"

#include "../dc/Bounds.h"

namespace uml {

UMLShape::UMLShape(const QString& umlType)
    : UMLDiagramElement(umlType) {}

void UMLShape::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLDiagramElement::fromJson(json, errorList);
    bounds_ = JsonSerializable::create<Bounds>(json.value("bounds"), errorList);

}

void UMLShape::toJson(QJsonObject& json) {
    UMLDiagramElement::toJson(json);
    if (bounds_) {
        QJsonObject bounds_json;
        bounds_->toJson(bounds_json);
        json.insert("bounds", bounds_json);
    }
}

/// <summary>
/// bounds getter
/// the optional bounds of the shape relative to the origin of its nesting plane.
/// </summary>
shared_ptr<Bounds> UMLShape::bounds() const {
    return bounds_;
}

/// <summary>
/// bounds setter
/// the optional bounds of the shape relative to the origin of its nesting plane.
/// </summary>
void UMLShape::setBounds(shared_ptr<Bounds> value) {
    bounds_ = value;
}

} // namespace uml
